﻿@{
    ViewBag.Title = "微信支付";
}
@{
    Layout = null;
}

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript" src="http://dev.pupuxing.net/assets/plugins/jquery-1.10.2.min.js"> </script>
    <script type="text/javascript" src="http://res.mail.qq.com/mmr/static/lib/js/lazyloadv3.js"></script>
    <script src="../../assets/js/wspay.js?v=1"></script>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta id="viewport" name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1; user-scalable=no;" />
    <script language="javascript">
        // 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
		alert('@Html.Raw(@ViewBag.Package)');
            WeixinJSBridge.invoke('getBrandWCPayRequest', {
                    "appId": "@ViewBag.AppId", //公众号名称，由商户传入
                "timeStamp": "@ViewBag.TimeStamp", //时间戳
                "nonceStr": "@ViewBag.NonceStr", //随机串
                "package": "@Html.Raw(@ViewBag.Package)",//扩展包
                "signType": "@ViewBag.SignType", //微信签名方式:1.sha1
                "paySign": "@ViewBag.Sign" //微信签名
                }, function (res) {
                    if (res.err_msg == "get_brand_wcpay_request:ok") {
                        window.location.href = paymentCompleleUrl;
                    }
                    if (res.err_msg == "get_brand_wcpay_request:cancel") {
                        window.history.back(-1);
                    }
                    // 使用以上方式判断前端返回,微信团队郑重提示：res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
                    //因此微信团队建议，当收到ok返回时，向商户后台询问是否收到交易成功的通知，若收到通知，前端展示交易成功的界面；若此时未收到通知，商户后台主动调用查询订单接口，查询订单的当前状态，并反馈给前端展示相应的界面。
                });
            WeixinJSBridge.log('yo~ ready.');
        }, false);
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

